﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Urb.Weather.Core.MeasureUnit;

namespace Urb.Weather.Ticker.UI.Converters
{
    [ValueConversion(typeof(TemperatureUnit), typeof(string))]
    public class TemperatureUnitConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || !(value is TemperatureUnit))
                return string.Empty;

            var temperatureUnit = (TemperatureUnit) value;

            switch (temperatureUnit)
            {
                case TemperatureUnit.Celsius:
                    return "°C";
                case TemperatureUnit.Fahrenheit:
                    return "F";
                default:
                    return "unknown";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
